package com.yu.crm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.crm.domain.pojo.ProSoftware;
import com.yu.crm.domain.request.FileRequest;
import com.yu.crm.domain.response.ProSoftwareRep;
import com.yu.crm.service.impl.ProSoftwareService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

/**
 * <p>
 * 软件表 前端控制器
 * </p>
 *
 * @author zds
 * @since 2021-04-02
 */
@Api(tags = "软件升级管理")
@RestController
@RequestMapping("/pro-software")
public class ProSoftwareController {

    @Autowired
    private ProSoftwareService proSoftwareService;

    @ApiOperation(value = "软件上传")
    @PostMapping("/upload")
    public void upload(@Valid FileRequest fileRequest) {
        proSoftwareService.upload(fileRequest);
    }

    @ApiOperation(value = "查询版本")
    @GetMapping(value = "/appVersionCheck")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appId", value = "APPID", required = true)
    })
    public ProSoftwareRep getPage(@RequestParam String appId) {
        return proSoftwareService.getVersion(appId);
    }

    @ApiOperation(value = "查询列表")
    @GetMapping(value = "/page")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "condition", value = "查询条件")
    })
    public IPage<ProSoftware> getPage(@ApiIgnore Page<ProSoftware> page,
                                      @RequestParam(required = false) String condition) {
        return proSoftwareService.getPage(page, condition);
    }
}

